import { Component, Injector, OnInit } from '@angular/core';
import { SFUISchema } from '@delon/form';
import { STComponentBase } from '@shared/itcore/components/st-component-base';
import { ItcoreSTColumn } from '@shared/itcore/services/alain.types';

@Component({
  selector: 'app-entityinfo',
  templateUrl: './entityinfo.component.html',
  styles: [],
})
export class EntityinfoComponent extends STComponentBase implements OnInit {
  constructor(injector: Injector) {
    super(injector);
    this.moduleName = 'entityinfo';
  }

  ngOnInit() {
    super.InitBase();
  }

  protected GetSTColumns(): ItcoreSTColumn[] {
    return [
      {
        title: '操作',
        fixed: 'left',
        width: 65,
        buttons: [{ text: '修改', icon: 'edit', iif: (row) => row.Updatable, click: (row) => this.edit(row) }],
      },
      { title: '实体名称', index: 'Name', editable: true, ftype: 'string', filterable: true },
      { title: '实体类型', index: 'TypeName', editable: true, ftype: 'string', filterable: true },
      { title: '数据审计', index: 'AuditEnabled', type: 'yn', editable: true, filterable: true },
    ];
  }

  protected GetSFUISchema(): SFUISchema {
    const ui: SFUISchema = {
      '*': { spanLabelFixed: 100, grid: { span: 12 } },
      $Name: { grid: { span: 24 }, widget: 'text' },
      $TypeName: { grid: { span: 24 }, widget: 'text' },
      $AuditEnabled: { grid: { span: 24 } },
    };
    return ui;
  }
}
